<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
  xmlns:DentalGUIHelper="clr-namespace:DentalGUIHelper;assembly=DentalConfig">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="MaterialDesignTheme.NamedTextBlock.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <Style x:Key="WrappingTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource TextBlockBase}">
    <Setter Property="TextWrapping" Value="Wrap"/>
  </Style>

  <ControlTemplate x:Key="MaskedColoredAreaTemplate" TargetType="{x:Type DentalGUIHelper:InfoBox}">
    <Expander Margin="-12,0" Style="{DynamicResource MaterialDesignHeaderlessExpander}" IsExpanded="{TemplateBinding IsExpanded}">
      <wpf:Card Margin="0,4" UniformCornerRadius="0" Background="{TemplateBinding Background}">
        <DockPanel MinHeight="{TemplateBinding BoxMinHeight}" x:Name="PART_ContentPanel">
          <Grid Width="{TemplateBinding IconAreaWidth}" DockPanel.Dock="Left" Background="{TemplateBinding IconAreaBackground}" ClipToBounds="True">
            <Canvas x:Name="ContentCanvas" Margin="{TemplateBinding IconAreaPadding}" Width="{Binding ActualWidth, ElementName=InfoIconArea}" Height="{Binding ActualHeight, ElementName=InfoIconArea}" HorizontalAlignment="Center" VerticalAlignment="Center">
              <DentalGUIHelper:RecoloredPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{TemplateBinding IconAreaForeground}">
                <ContentPresenter x:Name="InfoIconArea" TextElement.FontSize="32" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding IconAreaContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"/>
              </DentalGUIHelper:RecoloredPresenter>
            </Canvas>
          </Grid>
          <ContentPresenter Content="{TemplateBinding Content}" Margin="8,4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <ContentPresenter.Resources>
              <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WrappingTextBlock}">
                <Setter Property="VerticalAlignment" Value="Center"/>
              </Style>
            </ContentPresenter.Resources>
          </ContentPresenter>
        </DockPanel>
      </wpf:Card>
    </Expander>
    <ControlTemplate.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter TargetName="InfoIconArea" Property="Opacity" Value="{DynamicResource DisabledOpacity}" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style x:Key="MaterialDesignInfoBox" TargetType="{x:Type DentalGUIHelper:InfoBox}">
    <Style.Resources>
      <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WrappingTextBlock}"/>
    </Style.Resources>
    <Setter Property="IconAreaBackground" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="IconAreaForeground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
    <Setter Property="IconAreaPadding" Value="24"/>
    <Setter Property="IconAreaMaxWidth" Value="100"/>
    <Setter Property="BoxMinHeight" Value="80"/>
    <Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
    <Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialDesignBody}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type DentalGUIHelper:InfoBox}">
          <Expander Margin="-12,0" Style="{DynamicResource MaterialDesignHeaderlessExpander}" IsExpanded="{TemplateBinding IsExpanded}">
            <wpf:Card Margin="0,4" UniformCornerRadius="0" Background="{TemplateBinding Background}">
              <DockPanel MinHeight="{TemplateBinding BoxMinHeight}" x:Name="PART_ContentPanel">
                <Grid Width="{TemplateBinding IconAreaWidth}" DockPanel.Dock="Left" Background="{TemplateBinding IconAreaBackground}" ClipToBounds="True">
                  <wpf:PackIcon x:Name="DefaultInfoIcon" Kind="InformationCircleOutline" Height="32" Width="32" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding IconAreaForeground}" Visibility="Collapsed"/>
                  <Canvas x:Name="ContentCanvas" Margin="{TemplateBinding IconAreaPadding}" Width="{Binding ActualWidth, ElementName=InfoIconArea}" Height="{Binding ActualHeight, ElementName=InfoIconArea}" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <ContentPresenter x:Name="InfoIconArea" TextElement.FontSize="32" TextElement.Foreground="{TemplateBinding IconAreaForeground}" Content="{Binding IconAreaContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"/>
                  </Canvas>
                </Grid>
                <ContentPresenter Content="{TemplateBinding Content}" Margin="8,4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                  <ContentPresenter.Resources>
                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WrappingTextBlock}">
                      <Setter Property="VerticalAlignment" Value="Center"/>
                    </Style>
                  </ContentPresenter.Resources>
                </ContentPresenter>
              </DockPanel>
            </wpf:Card>
          </Expander>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding ElementName=InfoIconArea, Path=Content}" Value="{x:Null}">
              <Setter TargetName="DefaultInfoIcon" Property="Visibility" Value="Visible"/>
              <Setter TargetName="InfoIconArea" Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter TargetName="DefaultInfoIcon" Property="Opacity" Value="{DynamicResource DisabledOpacity}" />
              <Setter TargetName="InfoIconArea" Property="Opacity" Value="{DynamicResource DisabledOpacity}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="MaskIconArea" Value="True">
        <Setter Property="Template" Value="{StaticResource MaskedColoredAreaTemplate}"/>
      </Trigger>
    </Style.Triggers>
  </Style>

  <Style x:Key="MaterialDesignWarningBox" TargetType="{x:Type DentalGUIHelper:InfoBox}" BasedOn="{StaticResource MaterialDesignInfoBox}">
    <Setter Property="MaskIconArea" Value="True"/>
    <Setter Property="IconAreaContent">
      <Setter.Value>
        <wpf:PackIcon Kind="AlertOutline" Height="32" Width="32"/>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type DentalGUIHelper:InfoBox}" TargetType="{x:Type DentalGUIHelper:InfoBox}" BasedOn="{StaticResource MaterialDesignInfoBox}"/>
</ResourceDictionary>
